package com.nuc.bigdata.config.builder;

import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.StringVendorExtension;
import springfox.documentation.service.VendorExtension;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @author tianhao.luo
 * @date 2019/12/11 16:35
 */
public class MySwaggerBuilder implements Builder {
    /**
     * 标题
     **/
    private String title;
    /**
     * 描述
     **/
    private String description;
    /**
     * 版本
     **/
    private String version;

    private String termsOfServiceUrl;

    private Contact contact;

    private String license;
    private String licenseUrl;

    public Collection<VendorExtension> setCollection() {
        StringVendorExtension vendorExtension = new StringVendorExtension("名", "值");
        ArrayList<VendorExtension> vendorExtensions = new ArrayList<>();
        vendorExtensions.add(vendorExtension);
        return vendorExtensions;
    }

    @Override
    public void setTitle(String title) {
        this.title = title;
    }

    @Override
    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public void setVersion(String version) {
        this.version = version;
    }

    @Override
    public void setTermsOfServiceUrl(String termsOfServiceUrl) {
        this.termsOfServiceUrl = termsOfServiceUrl;
    }

    @Override
    public void setContact(Contact contact) {
        this.contact=contact;
    }


    @Override
    public void setLicense(String license) {
        this.license = license;
    }

    @Override
    public void setLicenseUrl(String licenseUrl) {
        this.licenseUrl = licenseUrl;
    }

    @Override
    public ApiInfo build() {
        return new ApiInfo(this.title, this.description, this.version, this.termsOfServiceUrl,
                this.contact,this.license,this.licenseUrl,setCollection());
    }
}
